/**
 * Created by Adi(adi@imeth.cn) on 2018/8/29.
 */
import { queryBankList, getBankById, updateBank, saveBank } from '../services/platfrom';
import { Request } from '../common/Request';

const modelRequest = new Request([
  {
    type: 'bankList',
    requestWay: queryBankList,
  },
  {
    type: 'getById',
    requestWay: getBankById,
  },
  {
    type: 'save',
    requestWay: saveBank,
  },
  {
    type: 'update',
    requestWay: updateBank,
  },
]);

export default {
  namespace: 'Bank',

  state: {
    bankList: [],
    bankDetail: {},
    saveStatus: {},
    updateStatus: {},
  },

  effects: modelRequest.effects,
  //   {
  //   * bankList({ payload = {} }, { call, put }) {
  //     const response = yield call(queryBankList, payload);
  //     yield put({
  //       type: 'queryBankList',
  //       payload: response,
  //     });
  //   },
  //   * getById({ payload = {} }, { call, put }) {
  //     yield put({
  //       type: 'getBankDetail',
  //       payload: {sign: 'doing'},
  //     });
  //     const response = yield call(getBankById, payload.id);
  //     yield put({
  //       type: 'getBankDetail',
  //       payload: {
  //         ...response,
  //         sign: 'done'
  //       },
  //     });
  //   },
  //   * update({ payload = {} }, { call, put }) {
  //     yield put({
  //       type: 'updateBank',
  //       payload: {sign: 'doing'},
  //     });
  //     const response = yield call(updateBank, payload);
  //     yield put({
  //       type: 'updateBank',
  //       payload: {
  //         ...response,
  //         sign: 'done'
  //       },
  //     });
  //   },
  //   * save({ payload = {} }, { call, put }) {
  //     yield put({
  //       type: 'saveBank',
  //       payload: {sign: 'doing'},
  //     });
  //     const response = yield call(saveBank, payload);
  //     yield put({
  //       type: 'saveBank',
  //       payload: {
  //         ...response,
  //         sign: 'done',
  //       },
  //     });
  //   },
  // },

  reducers: modelRequest.reducer,
  //   {
  //   queryBankList(state, action) {
  //     return {
  //       ...state,
  //       bankList: action.payload,
  //     };
  //   },
  //   getBankDetail(state, action) {
  //     return {
  //       ...state,
  //       bankDetail: action.payload,
  //     };
  //   },
  //   updateBank(state, action) {
  //     return {
  //       ...state,
  //       updateStatus: action.payload,
  //     };
  //
  //   },
  //   saveBank(state, action) {
  //     return {
  //       ...state,
  //       saveStatus: action.payload,
  //     };
  //   },
  // },
};
